# 微信公众号一键排版工具 - 启动脚本 (Windows PowerShell)

Write-Host "======================================" -ForegroundColor Cyan
Write-Host "  微信公众号一键排版工具 - 启动中" -ForegroundColor Cyan
Write-Host "======================================" -ForegroundColor Cyan
Write-Host ""

# 检查环境变量文件
if (-not (Test-Path "backend/.env")) {
    Write-Host "警告: 未找到 backend/.env 文件" -ForegroundColor Yellow
    Write-Host "请先配置环境变量，参考：环境配置说明.md" -ForegroundColor Yellow
    Write-Host ""
    $continue = Read-Host "是否继续启动？(y/n)"
    if ($continue -ne "y") {
        exit 0
    }
}

Write-Host "正在启动服务..." -ForegroundColor Yellow
Write-Host ""

# 启动后端（新窗口）
Write-Host "启动后端服务..." -ForegroundColor Green
Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd '$PSScriptRoot\backend'; Write-Host '后端服务启动中...' -ForegroundColor Cyan; node src/app.js"

# 等待2秒
Start-Sleep -Seconds 2

# 启动前端（新窗口）
Write-Host "启动前端服务..." -ForegroundColor Green
Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd '$PSScriptRoot\frontend'; Write-Host '前端服务启动中...' -ForegroundColor Cyan; npm run dev"

Write-Host ""
Write-Host "======================================" -ForegroundColor Cyan
Write-Host "  服务启动完成！" -ForegroundColor Green
Write-Host "======================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "访问地址:" -ForegroundColor Yellow
Write-Host "  前端：http://localhost:5173" -ForegroundColor White
Write-Host "  后端：http://localhost:3000" -ForegroundColor White
Write-Host "  健康检查：http://localhost:3000/health" -ForegroundColor White
Write-Host ""
Write-Host "按任意键关闭此窗口..." -ForegroundColor Gray
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

